/**
 * Created by Jacky
 *
 * brief :
 */


var http = require('http');

exports.request = function(opts, success, error){
    // TODO
    //var url = opts.url,

};

exports.get = function(url, success, error){
    http.get(url, function(res){
        if(res.statusCode > 400) return;
        var size = 0;
        var chunks = [];
        res.on('data', function(chunk){
            size += chunk.length;
            chunks.push(chunk);
        });
        res.on('end', function(){
            var data = Buffer.concat(chunks, size);
            success(data.toString());
        });
    }).on('error', function(){
        console.log("错误：" + e.message);
    });
};